﻿using Apewer;
using System.Reflection;

namespace Apewer.Internals
{

    internal class AssemblyHelper
    {

        /// <summary>获取当前进程程序集的资源。</summary>
        public static byte[] GetResource(string argName)
        {
            var assembly = Assembly.GetExecutingAssembly();
            return GetResource(assembly, argName);
        }

        /// <summary>获取指定程序集的资源。</summary>
        public static byte[] GetResource(Assembly argAssembly, string argName)
        {
            var result = Constant.EmptyBytes;
            if (argAssembly == null) return null;
            try
            {
                var assembly = Assembly.GetExecutingAssembly();
                var source = assembly.GetManifestResourceStream(argName);
                var destination = BytesUtility.Read(source);
                RuntimeUtility.Dispose(source);
            }
            finally { }
            return result;
        }

    }

}
